import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/**
 * @creationDate 2019/12/25
 */
import request from "../../utils/request";
import { getEnvConfig } from "../../utils/iocUtils";
/**
 * 查询TL多语言
 * {CPAAS_PLATFORM}/v1/multi-language
 * @export
 * @param {object} params - 查询参数
 * @param {string} params.fieldName - 查询的表单域名称
 * @param {string} params._token - token
 */

export function queryTL(_x) {
  return _queryTL.apply(this, arguments);
}
/**
 * 变更用户的默认语言选项
 * @export
 * {CPAAS_IAM}/cpaas/v1/users/default-language
 * @function updateDefaultLanguage
 * @param {!string} params.languageCode - 语言编码
 * @returns fetch Promise
 */

function _queryTL() {
  _queryTL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
    var _getEnvConfig, CPAAS_PLATFORM;

    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _getEnvConfig = getEnvConfig(), CPAAS_PLATFORM = _getEnvConfig.CPAAS_PLATFORM;
            return _context.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/multi-language"), {
              method: 'GET',
              query: params
            }));

          case 2:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _queryTL.apply(this, arguments);
}

export function updateDefaultLanguage(_x2) {
  return _updateDefaultLanguage.apply(this, arguments);
}

function _updateDefaultLanguage() {
  _updateDefaultLanguage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
    var _getEnvConfig2, CPAAS_IAM;

    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            _getEnvConfig2 = getEnvConfig(), CPAAS_IAM = _getEnvConfig2.CPAAS_IAM;
            return _context2.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/default-language"), {
              method: 'PUT',
              query: params
            }));

          case 2:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _updateDefaultLanguage.apply(this, arguments);
}